package com.example.qxfw.mongodb.hy.service.impl;

import com.example.qxfw.mongodb.hy.entity.HyTxtFile;
import com.example.qxfw.mongodb.hy.service.TxtFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;

@Service
public class TxtFileServiceImpl implements TxtFileService {

    @Qualifier("mongoSecondTemplate")
    @Autowired
    private MongoTemplate mongoTemplate;

    @Override
    public HyTxtFile getByTableId(String id) {
        return mongoTemplate.findOne(new Query(Criteria.where("id").is(id)), HyTxtFile.class);
    }

    @Override
    public HyTxtFile save(HyTxtFile hyTxtFile) {
        return mongoTemplate.save(hyTxtFile);
    }
}
